package com.example.demo.config;

import com.example.demo.model.Phone;
import com.example.demo.service.RandomStringService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;

@Configuration
public class DbConfig {

    private final RandomStringService randomStringService;

    @Autowired
    public DbConfig(RandomStringService randomStringService) {
        this.randomStringService = randomStringService;
    }
    @Bean
//    @Scope("prototype") // This is to create a new instance of the bean for each request
    public Phone getPhone() {

        return new Phone(randomStringService);
    }

}
